home *** CD-ROM | disk | FTP | other *** search
/ Commodore Free 33R1 / Commodore_Free_Issue_33R1_2009_Commodore_Computer_Club.d64 / c16+4 pages < prev    next >
Text File  |  2023-02-26  |  7KB  |  255 lines

  1. .
  2. *************************************
  3.    Commodore 16 and plus 4 pages
  4.      Created By John Fielden
  5. *************************************
  6.  
  7. Hi. c16 fans. Apologies, if I've
  8. missed a month or so. It seems
  9. everything piles up all at once..
  10. For those wondering how long I may be
  11. around. Subject to the editors kind
  12. hospitality, and health permitting I
  13. hope to eventually demonstrate that
  14. some programs for other formats such
  15. as The Amiga and beyond can work on
  16. the c16/plus4.
  17. (COMMODORE FREE you are welcome here
  18. and I look forward to other
  19. programming excursions')
  20.  
  21. Before we start with the essential
  22. debugging.
  23.  
  24. It is important to note that the
  25. extremely long program called
  26. "Business Calculator" will work on a
  27. genuine Commodore16.  But you might
  28. need to strip away the non-essentials
  29. to preserve memory when saving.  Like
  30. the many lines of instructions that
  31. aren't needed as you already have
  32. them in the magazine!  You can change
  33. the border colour control to lose the
  34. menu, and instead of up and down
  35. controls.  Just have it going one way
  36. when the user presses 'c', and
  37. resetting at the upper bound to the
  38. lowest legal number -or, vice versa,
  39. if you prefer.  The last main change
  40. I can think of is to take out the
  41. first program.  "VAT Calculator".  To
  42. give some assistance with this I have
  43. included as a stand alone programme
  44. for this months feast, Though it may
  45. vary slightly.  You already have the
  46. original accompanying notes, So even
  47. the most inexperienced novice should
  48. be ok.
  49.  
  50. Having said all that.
  51.  
  52. Both programmes should work on the
  53. other commodore 8bit formats like
  54. VIC-20 or C=64 as there are no POKE
  55. or PEEK commands.  In fact, the only
  56. stumbling block I can see is The
  57. "SCNCLR" command, which means Screen
  58. Clear.  And can be changed to PRINT"
  59. and then press shift and CLR HME key
  60. ".  On other formats this may convert
  61. to CLS.
  62.  
  63. Debugging
  64.  
  65. In order to keep enjoying something;
  66. It is important to take the time to
  67. play.  In fact if something is new
  68. then 70 or even 80 percent of the
  69. time with it should be spent on
  70. little else.  In theory, the more
  71. time you spend with something the
  72. better you get.  Of course learning
  73. to get things right first time is
  74. preferential, if you can manage to.
  75. But often the best programmers are
  76. those who learned to deal with
  77. getting it wrong. (So, I must fast
  78. becoming some kind of
  79. "Guru"...Any-one seen the film???
  80. -enough of that!)
  81.  
  82. The other day I saw fit to purchase a
  83. newer computer. (new to me at least).
  84. In the process, I decided to play
  85. around with  YAPE, the c16/plus4
  86. emulator for windows PCs. available
  87. through www.commodore16.com And so
  88. having copied it across wrote the
  89. following:-
  90.  
  91. 10 FORJ=0TO20
  92. 20 COLOR0,,J
  93. 30 NEXT J
  94.  
  95. First, it is worth noting in line 30.
  96. The 'J' is optional.  But it is good
  97. programming practice to have it in as
  98. it makes the program easier to read.
  99. Second, the response I got on typing
  100. RUN was as follows:-
  101.  
  102. SYNTAX ERROR IN 20
  103.  
  104. It became obvious there are two
  105. commas, where there should be only
  106. one. So corrected this; and just
  107. assuming that was it, I again typed
  108. RUN.
  109. Still the above. error
  110.  
  111. The program still being on screen, I
  112. could see that "colour" is spelt how
  113. the computer likes it.  So I typed
  114.  
  115. PRINT J
  116.  
  117. Producing the answer 0.
  118.  
  119. typing HELP still brought the
  120. insistence that line 20 is somehow
  121. wrong.  I've checked spelling, and
  122. corrected typos.  The 0, is a valid
  123. command in the line. i.e. ...0,J  So
  124. what is wrong?
  125.  
  126. Try changing line 10 ...J=1 to...
  127.  
  128. You'll see the effect.  Try adding
  129.  
  130. 25 fork=1to350:nextk
  131.  
  132. you might add after that
  133.  
  134.  :PrintJ
  135.  
  136. I still got the error message
  137.  
  138. ILLEGAL QUANTITY ERROR IN 20
  139.  
  140. To find why type
  141.  
  142. print j
  143.  
  144. We find the value of the variable 'j'
  145. and see it must be over.  So change
  146. line 10 where it says ...20 to the
  147. value one less from the computers
  148. complaining and whining on.
  149. (Honestly!  Computers are soooo
  150. clever you'd think they'd be able to
  151. correct little things like this
  152. themselves!  NOPE.)
  153.  
  154. A useful program for finding the
  155. colour, or combinations you like
  156. best.  Try adding a random element,
  157. and a line for colour 4,l The border.
  158. You might go through all the
  159. combinations of the background with
  160. one border colour.  Before moving to
  161. the next.  If you need help with such
  162. a program, let me know.
  163.  
  164. More fun (or "messing about" if you
  165. wish to be critical) brought about
  166. this program.  Try to work out what
  167. is wrong before looking at the
  168. answers.  A nice easy one.
  169.  
  170. 10 PRINT"JOHN",X
  171. 20 IF X=4 THEN END
  172. 30 FOR X=1 TO 9
  173. 40 GOTO10
  174. 50 NEXT X
  175.  
  176. Questions
  177.  
  178. Try working out what will happen,
  179. before typing RUN. if you guess
  180. correctly, you won't need the answers
  181. below:-
  182. What is the absolute unnecessary line
  183. in the listing?
  184.  
  185. How should the program list?
  186.  
  187. Answers.
  188. Type RUN to see if you were correct.
  189. You don't need the goto statement, if
  190. you're line order is correct.
  191.  
  192. The correct order is:-
  193. 10 should be 20, 30 should be 10,
  194. while what was 20 (ifx=4...) fits at
  195. 30.  Either delete 40,  or put REM in
  196. front of it, and leave it intact as a
  197. reminder of the folly of trying to be
  198. clever with coding.
  199.  
  200. Programs This month
  201.  
  202. We've covered VAT Calc. already.
  203.  
  204. Tally Counter:  Have you ever been in
  205. a situation where you need to quickly
  206. make and remember a count of
  207. something, or even multiple things.
  208. This program saves paper, even with
  209. the cleverly devised system of 4 1s,
  210. followed by a strikethrough for 5.
  211. In case you don't know what this is;
  212. "GraphicTally" is designed to show
  213. you.  But, please don't expect too
  214. many graphic programs as I am by no
  215. means competent at drawing.
  216.  
  217. GraphicTally:  An interesting
  218. demonstration of the tally mark as it
  219. is/was used on paper.  Of course the
  220. above program may reduce such a need.
  221. It's still useful to know, if you
  222. didn't already.  The program has the
  223. added benefit of helping to
  224. understand the plotting of graphics.
  225. And there is a way to write the
  226. program using loops and maths and
  227. reducing program size, but as it does
  228. less to show the plotting, was less
  229. appealing for this exercise. If you
  230. key in lines from 2000 early, you can
  231. run the program after about line 50
  232. every two or three lines to get a
  233. feel for the progress.
  234.  
  235. Finally, the first version didn't
  236. save! The pains I've been through.
  237. If you saw the amount of error
  238. corrections I had to do.  You might
  239. become a genius overnight! This skill
  240. will come in advancing the program.
  241. To give you an idea; try making an
  242. educational program for young
  243. children. Timing how fast they can
  244. count a random number of tallys
  245. appearing on screen. And even make a
  246. competition with two or more players.
  247. (I may print this in a future
  248. edition, but see how you go, as it
  249. will show how there are different
  250. ways of doing the same thing).
  251.  
  252. Happy Programming
  253. Jn.
  254.  
  255. =====================================